package src.java.SingleTon;

public class Singleton1 {
    //饿汉式：类加载时就初始化
    //优点：没有锁，执行效率高，线程安全
    //缺点：类加载时就初始化，浪费内存

    //创建对象
    private static Singleton1 instance = new Singleton1();
    //private 使该类无法实例化
    private Singleton1(){}
    //获取唯一可用的对象
    public static Singleton1 getInstance(){
        return instance;
    }
}
